package com.bosssoft.boss_exam_db.service.busines.impl;

import com.bosssoft.boss_exam_db.entity.Company;
import com.bosssoft.boss_exam_db.entity.MyGroup;
import com.bosssoft.boss_exam_db.mapper.DashboardMapper;
import com.bosssoft.boss_exam_db.mapper.GroupMapper;
import com.bosssoft.boss_exam_db.service.busines.DashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.HashMap;


@Service
public class DashboardServiceImpl implements DashboardService {

    //引入集团Mapper
    @Autowired
    private GroupMapper groupMapper;

    // 引入面板Mapper
    @Autowired
    private DashboardMapper dashboardMapper;

    /***
     * @Author lys(cherish)
     * @Phone 17720799636
     * @Date  2019/4/8
     * @Description 获取公司记录数
     * @Param [company] 公司
     * @Return java.lang.Object
     * @Exception
     * @since JDK 1.8
     **/
    @Override
    public Object getCoutShow(Company company) {
        HashMap<String, Integer> dashboardMap = new HashMap<>();
        // 获取公司应聘人总数
        Integer applicantTotal =dashboardMapper.queryApplicantTotalByCompany(company.getId());
        dashboardMap.put("applicantTotal",applicantTotal);
        //集团应聘总人数
        Integer allApplicantTotal = dashboardMapper.queryApplicantTotalByGroup(company.getGroupId());
        dashboardMap.put("allApplicantTotal",allApplicantTotal);
        //todo 注册人数排序暂时未实现
        dashboardMap.put("applicantNumOrder",0);
        //        获取注册集团数量
        Example example = new Example(MyGroup.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("deleted",false);
        int groupTotal = groupMapper.selectCountByExample(example);
        dashboardMap.put("groupTotal",groupTotal);
        return dashboardMap;
    }
}
